# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self.name = ''
self.parental_rating = 0
self.service_name = ''
self.start_time = 0
self.stop_time = 0
self.size = 0
self.url = ''
self.info_file_path_name = ''
self.files = {}
self.files_folder = ''
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775c94c>}
nname: 92
n 92(None)[return text
]:
	i: 0(AL), 91()
	o: 

nname: 91
n 91(None)[]:
	i: 49(AF), 65()
	o: 92()

nname: 65
n 65(None)[for id, file in self.files.items():
text += 'File %s\n' % file
]:
	i: 49(for)
	o: 91()

nname: 49
n 49(None)[]:
	i: 0(loop)
	o: 65(for), 91(AF)

nname: 0
n 0(None)[text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
]:
	i: 
	o: 49(loop), 92(AL)

nname: 92
n 92(None)[return text
]:
	i: 65()
	o: 

nname: 65
n 65(None)[for id, file in self.files.items():
	text += 'File %s\n' % file
]:
	i: 0(for)
	o: 92()

nname: 0
n 0(None)[text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
]:
	i: 
	o: 65(for)

nname: 92
n 92(None)[return text
]:
	i: 0()
	o: 

nname: 0
n 0(None)[text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
for id, file in self.files.items():
	text += 'File %s\n' % file
]:
	i: 
	o: 92()

nname: 0
n 0(None)[text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
for id, file in self.files.items():
	text += 'File %s\n' % file
return text
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775c7ac>}
nname: 256
n 256(None)[]:
	i: 241(), 245(), 255(AE)
	o: 

nname: 245
n 245(None)[]:
	i: 0(except)
	o: 256()

nname: 241
n 241(None)[]:
	i: 156(AL), 240()
	o: 256()

nname: 240
n 240(None)[]:
	i: 162(AF), 236()
	o: 241()

nname: 236
n 236(None)[]:
	i: 169(f), 223()
	o: 240()

nname: 223
n 223(None)[self.parental_rating = maturity_rating
continue
]:
	i: 169(t)
	o: 236()

nname: 169
n 169(maturity_rating > self.parental_rating)[for epg in programs_list:
maturity_rating = int(epg.get('rating', epg.get('maturityRating', 0)))
]:
	i: 162(for)
	o: 223(t), 236(f)

nname: 162
n 162(None)[]:
	i: 156(loop)
	o: 169(for), 240(AF)

nname: 156
n 156(None)[programs_list = browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options)
]:
	i: 12(t), 152()
	o: 162(loop), 241(AL)

nname: 152
n 152(None)[]:
	i: 12(f)
	o: 156()

nname: 12
n 12(browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options))[service = container_search(get_root('channel'), 'title', self.service_name)[0]
options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
]:
	i: 0(try)
	o: 152(f), 156(t)

nname: 0
n 0(None)[self.parental_rating = 0
]:
	i: 
	o: 12(try), 245(except)

nname: 256
n 256(None)[]:
	i: 245(), 156(AL), 162(AF), 169()
	o: 

nname: 245
n 245(None)[except:
	pass
]:
	i: 0()
	o: 256()

nname: 169
n 169(None)[for epg in programs_list:
maturity_rating = int(epg.get('rating', epg.get('maturityRating', 0)))
if maturity_rating > self.parental_rating:
	self.parental_rating = maturity_rating
	continue
]:
	i: 162(for)
	o: 256()

nname: 162
n 162(None)[]:
	i: 156(loop)
	o: 169(for), 256(AF)

nname: 156
n 156(None)[programs_list = browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options)
]:
	i: 0(t)
	o: 162(loop), 256(AL)

nname: 0
n 0(None)[self.parental_rating = 0
try:
	service = container_search(get_root('channel'), 'title', self.service_name)[0]
	options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
	if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
		pass
]:
	i: 
	o: 156(), 245()

nname: 256
n 256(None)[]:
	i: 245(), 169()
	o: 

nname: 245
n 245(None)[except:
	pass
]:
	i: 0()
	o: 256()

nname: 169
n 169(None)[for epg in programs_list:
	maturity_rating = int(epg.get('rating', epg.get('maturityRating', 0)))
	if maturity_rating > self.parental_rating:
		self.parental_rating = maturity_rating
		continue
]:
	i: 156(for)
	o: 256()

nname: 156
n 156(None)[programs_list = browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options)
]:
	i: 0(t)
	o: 169(for)

nname: 0
n 0(None)[self.parental_rating = 0
try:
	service = container_search(get_root('channel'), 'title', self.service_name)[0]
	options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
	if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
		pass
]:
	i: 
	o: 156(), 245()

nname: 256
n 256(None)[]:
	i: 245(), 156()
	o: 

nname: 245
n 245(None)[except:
	pass
]:
	i: 0()
	o: 256()

nname: 156
n 156(None)[programs_list = browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options)
for epg in programs_list:
	maturity_rating = int(epg.get('rating', epg.get('maturityRating', 0)))
	if maturity_rating > self.parental_rating:
		self.parental_rating = maturity_rating
		continue
]:
	i: 0(t)
	o: 256()

nname: 0
n 0(None)[self.parental_rating = 0
try:
	service = container_search(get_root('channel'), 'title', self.service_name)[0]
	options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
	if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
		pass
]:
	i: 
	o: 156(), 245()

self.nodes: {0: <unpyclib.structure.node instance at 0xb77619ac>, 256: <unpyclib.structure.node instance at 0xb77616ec>, 245: <unpyclib.structure.node instance at 0xb77615ec>, 156: <unpyclib.structure.node instance at 0xb776180c>}
nname: 47
n 47(None)[return False
]:
	i: 34(JA), 42(), 46()
	o: 

nname: 46
n 46(None)[]:
	i: 0(f)
	o: 47()

nname: 42
n 42(None)[]:
	i: 15(f)
	o: 47()

nname: 34
n 34(None)[return True
]:
	i: 15(t)
	o: 47(JA)

nname: 15
n 15(self.url.startswith(URL_PREFIX_TIMESHIFT))[]:
	i: 0(t)
	o: 34(t), 42(f)

nname: 0
n 0(self.url != '')[]:
	i: 
	o: 15(t), 46(f)

nname: 0
n 0(None)[if self.url != '':
	if self.url.startswith(URL_PREFIX_TIMESHIFT):
		return True
return False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775cc2c>}
nname: 542
n 542(None)[return True
]:
	i: 513(), 541()
	o: 

nname: 541
n 541(None)[]:
	i: 341(t)
	o: 542()

nname: 513
n 513(None)[log.error("Failed to save Record info file '%s'" % self.info_file_path_name)
return False
]:
	i: 341(f)
	o: 542()

nname: 341
n 341(self.SaveToFile(self.info_file_path_name))[self.url = url
self.dvb_service_id = dvb_service_id
self.info_file_path_name = os.path.join(path_name, file_name)
self.files_folder = os.path.dirname(self.info_file_path_name)
log.info('files = ' + str(self.files))
log.info('url = ' + str(self.url))
log.info('filename = ' + str(self.info_file_path_name))
self.compute_parental_rating()
]:
	i: 291(), 319()
	o: 513(f), 541(t)

nname: 319
n 319(None)[log.critical("ERROR : BUG TO FIX : BAD URL Prefix for a recording ! : url='%s'" % url)
return False
]:
	i: 0(f)
	o: 341()

nname: 291
n 291(None)[self.size = len(self.files) * config.timeshift_chunk_max_size
]:
	i: 134(AL), 290()
	o: 341()

nname: 290
n 290(None)[]:
	i: 143(AF), 269()
	o: 291()

nname: 269
n 269(None)[log.error("Can not extract record (timeshift) file index from '%s'" % file)
]:
	i: 150(f), 253()
	o: 290()

nname: 253
n 253(None)[self.files[index] = file
continue
]:
	i: 235(), 252()
	o: 269()

nname: 252
n 252(None)[]:
	i: 216(f)
	o: 253()

nname: 235
n 235(None)[log.critical('ERROR: BUG TO FIX : Several record (timeshift) files have same index !!!!')
]:
	i: 216(t)
	o: 253()

nname: 216
n 216(self.files.has_key(index))[]:
	i: 150(t)
	o: 235(t), 252(f)

nname: 150
n 150(index >= 0)[for file in _files:
log.debug(file)
index = int(file[len(config.timeshift_chunk_file_base_name):-len(config.timeshift_chunk_file_extention)])
]:
	i: 143(for)
	o: 216(t), 269(f)

nname: 143
n 143(None)[]:
	i: 134(loop)
	o: 150(for), 290(AF)

nname: 134
n 134(None)[index = 0
]:
	i: 90(), 119(), 132(AE)
	o: 143(loop), 291(AL)

nname: 132
n 132(None)[]:
	i: 109(f)
	o: 134(AE)

nname: 119
n 119(None)[#, e
return False
]:
	i: 109(t)
	o: 134()

nname: 109
n 109(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 42(except)
	o: 119(t), 132(f)

nname: 90
n 90(None)[_files = os.listdir(path_name)
]:
	i: 42(try)
	o: 134()

nname: 42
n 42(None)[file_path_name = os.path.split(url[len(URL_PREFIX_TIMESHIFT):])[0]
file_name = RECORD_INFO_FILE_NAME_MULTIPLE_FILE_NAME
path_name = file_path_name
]:
	i: 0(t)
	o: 90(try), 109(except)

nname: 0
n 0(url.startswith(URL_PREFIX_TIMESHIFT))[self.files = {}
self.url = ''
self.info_file_path_name = ''
]:
	i: 
	o: 42(t), 319(f)

nname: 341
n 341(None)[self.url = url
self.dvb_service_id = dvb_service_id
self.info_file_path_name = os.path.join(path_name, file_name)
self.files_folder = os.path.dirname(self.info_file_path_name)
log.info('files = ' + str(self.files))
log.info('url = ' + str(self.url))
log.info('filename = ' + str(self.info_file_path_name))
self.compute_parental_rating()
if not self.SaveToFile(self.info_file_path_name):
	log.error("Failed to save Record info file '%s'" % self.info_file_path_name)
	return False
return True
]:
	i: 291(), 319()
	o: 

nname: 319
n 319(None)[log.critical("ERROR : BUG TO FIX : BAD URL Prefix for a recording ! : url='%s'" % url)
return False
]:
	i: 0(f)
	o: 341()

nname: 291
n 291(None)[self.size = len(self.files) * config.timeshift_chunk_max_size
]:
	i: 109(AL), 143(AF), 269()
	o: 341()

nname: 269
n 269(None)[log.error("Can not extract record (timeshift) file index from '%s'" % file)
]:
	i: 150(f), 216()
	o: 291()

nname: 216
n 216(None)[if self.files.has_key(index):
	log.critical('ERROR: BUG TO FIX : Several record (timeshift) files have same index !!!!')
self.files[index] = file
continue
]:
	i: 150(t)
	o: 269()

nname: 150
n 150(index >= 0)[for file in _files:
log.debug(file)
index = int(file[len(config.timeshift_chunk_file_base_name):-len(config.timeshift_chunk_file_extention)])
]:
	i: 143(for)
	o: 216(t), 269(f)

nname: 143
n 143(None)[]:
	i: 109(loop)
	o: 150(for), 291(AF)

nname: 109
n 109(None)[except Exception, e:
	return False
index = 0
]:
	i: 42()
	o: 143(loop), 291(AL)

nname: 42
n 42(None)[file_path_name = os.path.split(url[len(URL_PREFIX_TIMESHIFT):])[0]
file_name = RECORD_INFO_FILE_NAME_MULTIPLE_FILE_NAME
path_name = file_path_name
try:
	_files = os.listdir(path_name)
]:
	i: 0(t)
	o: 109()

nname: 0
n 0(url.startswith(URL_PREFIX_TIMESHIFT))[self.files = {}
self.url = ''
self.info_file_path_name = ''
]:
	i: 
	o: 42(t), 319(f)

nname: 341
n 341(None)[self.url = url
self.dvb_service_id = dvb_service_id
self.info_file_path_name = os.path.join(path_name, file_name)
self.files_folder = os.path.dirname(self.info_file_path_name)
log.info('files = ' + str(self.files))
log.info('url = ' + str(self.url))
log.info('filename = ' + str(self.info_file_path_name))
self.compute_parental_rating()
if not self.SaveToFile(self.info_file_path_name):
	log.error("Failed to save Record info file '%s'" % self.info_file_path_name)
	return False
return True
]:
	i: 291(), 319()
	o: 

nname: 319
n 319(None)[log.critical("ERROR : BUG TO FIX : BAD URL Prefix for a recording ! : url='%s'" % url)
return False
]:
	i: 0(f)
	o: 341()

nname: 291
n 291(None)[self.size = len(self.files) * config.timeshift_chunk_max_size
]:
	i: 42(AL), 143(AF), 150()
	o: 341()

nname: 150
n 150(None)[for file in _files:
log.debug(file)
index = int(file[len(config.timeshift_chunk_file_base_name):-len(config.timeshift_chunk_file_extention)])
if index >= 0:
	if self.files.has_key(index):
		log.critical('ERROR: BUG TO FIX : Several record (timeshift) files have same index !!!!')
	self.files[index] = file
	continue
log.error("Can not extract record (timeshift) file index from '%s'" % file)
]:
	i: 143(for)
	o: 291()

nname: 143
n 143(None)[]:
	i: 42(loop)
	o: 150(for), 291(AF)

nname: 42
n 42(None)[file_path_name = os.path.split(url[len(URL_PREFIX_TIMESHIFT):])[0]
file_name = RECORD_INFO_FILE_NAME_MULTIPLE_FILE_NAME
path_name = file_path_name
try:
	_files = os.listdir(path_name)
except Exception, e:
	return False
index = 0
]:
	i: 0(t)
	o: 143(loop), 291(AL)

nname: 0
n 0(url.startswith(URL_PREFIX_TIMESHIFT))[self.files = {}
self.url = ''
self.info_file_path_name = ''
]:
	i: 
	o: 42(t), 319(f)

self.nodes: {0: <unpyclib.structure.node instance at 0x85b802c>, 291: <unpyclib.structure.node instance at 0x85b83ec>, 42: <unpyclib.structure.node instance at 0xb7764f0c>, 143: <unpyclib.structure.node instance at 0x85b81ec>, 341: <unpyclib.structure.node instance at 0xb7764f8c>, 150: <unpyclib.structure.node instance at 0xb7764d4c>, 319: <unpyclib.structure.node instance at 0x85b842c>}
nname: 140
n 140(None)[self.info_file_path_name = strFilePathNameName
self.files_folder = os.path.dirname(self.info_file_path_name)
return True
]:
	i: 122(), 139()
	o: 

nname: 139
n 139(None)[]:
	i: 107(t)
	o: 140()

nname: 122
n 122(None)[self.info_file_path_name = ''
return False
]:
	i: 107(f)
	o: 140()

nname: 107
n 107(self.LoadFromXML(node_root))[]:
	i: 71(), 106()
	o: 122(f), 139(t)

nname: 106
n 106(None)[]:
	i: 50(t)
	o: 107()

nname: 71
n 71(None)[log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
return False
]:
	i: 50(f)
	o: 107()

nname: 50
n 50(node_root)[node_root = node_root.find('record')
]:
	i: 3(), 22(), 49(AE)
	o: 71(f), 106(t)

nname: 22
n 22(None)[log.critical("Can not parse xml file '%s'" % strFilePathNameName)
return False
]:
	i: 0(except)
	o: 50()

nname: 3
n 3(None)[node_root = ET.parse(strFilePathNameName)
]:
	i: 0(try)
	o: 50()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 22(except)

nname: 107
n 107(None)[if not self.LoadFromXML(node_root):
	self.info_file_path_name = ''
	return False
self.info_file_path_name = strFilePathNameName
self.files_folder = os.path.dirname(self.info_file_path_name)
return True
]:
	i: 22()
	o: 

nname: 22
n 22(None)[except:
	log.critical("Can not parse xml file '%s'" % strFilePathNameName)
	return False
node_root = node_root.find('record')
if not node_root:
	log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
	return False
]:
	i: 0()
	o: 107()

nname: 0
n 0(None)[try:
	node_root = ET.parse(strFilePathNameName)
]:
	i: 
	o: 22()

nname: 107
n 107(None)[if not self.LoadFromXML(node_root):
	self.info_file_path_name = ''
	return False
self.info_file_path_name = strFilePathNameName
self.files_folder = os.path.dirname(self.info_file_path_name)
return True
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	node_root = ET.parse(strFilePathNameName)
except:
	log.critical("Can not parse xml file '%s'" % strFilePathNameName)
	return False
node_root = node_root.find('record')
if not node_root:
	log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
	return False
]:
	i: 
	o: 107()

nname: 0
n 0(None)[try:
	node_root = ET.parse(strFilePathNameName)
except:
	log.critical("Can not parse xml file '%s'" % strFilePathNameName)
	return False
node_root = node_root.find('record')
if not node_root:
	log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
	return False
if not self.LoadFromXML(node_root):
	self.info_file_path_name = ''
	return False
self.info_file_path_name = strFilePathNameName
self.files_folder = os.path.dirname(self.info_file_path_name)
return True
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776138c>}
nname: 444
n 444(None)[return True
]:
	i: 358(AL), 443()
	o: 

nname: 443
n 443(None)[]:
	i: 397(AF), 404()
	o: 444()

nname: 404
n 404(None)[for node_file in nodes_file:
self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
]:
	i: 397(for)
	o: 443()

nname: 397
n 397(None)[]:
	i: 358(loop)
	o: 404(for), 443(AF)

nname: 358
n 358(None)[self.url = node_information.find('url').text
nodes_file = node_files.getiterator('file')
]:
	i: 326(), 357()
	o: 397(loop), 444(AL)

nname: 357
n 357(None)[]:
	i: 161(f)
	o: 358()

nname: 326
n 326(None)[self.size = int(node_information.find('size').text)
]:
	i: 161(t)
	o: 358()

nname: 161
n 161(node_information.find('size'))[self.name = node_information.find('name').text
self.parental_rating = int(node_information.find('parental_rating').text)
self.service_name = node_information.find('channel').text
self.dvb_service_id = int(node_information.find('dvb_service_id').text)
self.start_time = int(node_information.find('start_time').text)
self.stop_time = int(node_information.find('stop_time').text)
]:
	i: 139(), 160()
	o: 326(t), 357(f)

nname: 160
n 160(None)[]:
	i: 112(f)
	o: 161()

nname: 139
n 139(None)[log.error("Invalide Record Info file : No 'files' xml node found")
return False
]:
	i: 112(t)
	o: 161()

nname: 112
n 112(node_files == None)[node_files = oXMLNode.find('files')
]:
	i: 90(), 111()
	o: 139(t), 160(f)

nname: 111
n 111(None)[]:
	i: 0(f)
	o: 112()

nname: 90
n 90(None)[log.error("Invalide Record Info file : No 'information' xml node found")
return False
]:
	i: 0(t)
	o: 112()

nname: 0
n 0(node_information == None)[self.files = {}
self.name = ''
self.parental_rating = 0
self.service_name = ''
self.start_time = 0
self.stop_time = 0
self.url = ''
node_information = oXMLNode.find('information')
]:
	i: 
	o: 90(t), 111(f)

nname: 443
n 443(None)[return True
]:
	i: 397()
	o: 

nname: 397
n 397(None)[for node_file in nodes_file:
	self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
]:
	i: 161(loop)
	o: 443()

nname: 161
n 161(None)[self.name = node_information.find('name').text
self.parental_rating = int(node_information.find('parental_rating').text)
self.service_name = node_information.find('channel').text
self.dvb_service_id = int(node_information.find('dvb_service_id').text)
self.start_time = int(node_information.find('start_time').text)
self.stop_time = int(node_information.find('stop_time').text)
if node_information.find('size'):
	self.size = int(node_information.find('size').text)
self.url = node_information.find('url').text
nodes_file = node_files.getiterator('file')
]:
	i: 0()
	o: 397(loop)

nname: 0
n 0(None)[self.files = {}
self.name = ''
self.parental_rating = 0
self.service_name = ''
self.start_time = 0
self.stop_time = 0
self.url = ''
node_information = oXMLNode.find('information')
if node_information == None:
	log.error("Invalide Record Info file : No 'information' xml node found")
	return False
node_files = oXMLNode.find('files')
if node_files == None:
	log.error("Invalide Record Info file : No 'files' xml node found")
	return False
]:
	i: 
	o: 161()

nname: 397
n 397(None)[for node_file in nodes_file:
	self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
return True
]:
	i: 0(loop)
	o: 

nname: 0
n 0(None)[self.files = {}
self.name = ''
self.parental_rating = 0
self.service_name = ''
self.start_time = 0
self.stop_time = 0
self.url = ''
node_information = oXMLNode.find('information')
if node_information == None:
	log.error("Invalide Record Info file : No 'information' xml node found")
	return False
node_files = oXMLNode.find('files')
if node_files == None:
	log.error("Invalide Record Info file : No 'files' xml node found")
	return False
self.name = node_information.find('name').text
self.parental_rating = int(node_information.find('parental_rating').text)
self.service_name = node_information.find('channel').text
self.dvb_service_id = int(node_information.find('dvb_service_id').text)
self.start_time = int(node_information.find('start_time').text)
self.stop_time = int(node_information.find('stop_time').text)
if node_information.find('size'):
	self.size = int(node_information.find('size').text)
self.url = node_information.find('url').text
nodes_file = node_files.getiterator('file')
]:
	i: 
	o: 397(loop)

nname: 0
n 0(None)[self.files = {}
self.name = ''
self.parental_rating = 0
self.service_name = ''
self.start_time = 0
self.stop_time = 0
self.url = ''
node_information = oXMLNode.find('information')
if node_information == None:
	log.error("Invalide Record Info file : No 'information' xml node found")
	return False
node_files = oXMLNode.find('files')
if node_files == None:
	log.error("Invalide Record Info file : No 'files' xml node found")
	return False
self.name = node_information.find('name').text
self.parental_rating = int(node_information.find('parental_rating').text)
self.service_name = node_information.find('channel').text
self.dvb_service_id = int(node_information.find('dvb_service_id').text)
self.start_time = int(node_information.find('start_time').text)
self.stop_time = int(node_information.find('stop_time').text)
if node_information.find('size'):
	self.size = int(node_information.find('size').text)
self.url = node_information.find('url').text
nodes_file = node_files.getiterator('file')
for node_file in nodes_file:
	self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
return True
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776406c>}
nname: 90
n 90(None)[tree = ET.ElementTree(root_node)
tree.write(strFilePathNameName, encoding='utf-8')
self.info_file_path_name = strFilePathNameName
os.fsync(os.open(strFilePathNameName, os.O_RDWR))
return True
]:
	i: 64(), 89()
	o: 

nname: 89
n 89(None)[]:
	i: 0(t)
	o: 90()

nname: 64
n 64(None)[log.critical("Failed to save recordinfo '%s'" % strFilePathNameName)
return False
]:
	i: 0(f)
	o: 90()

nname: 0
n 0(self.SaveToXMLNode(record_node))[root_node = ET.Element('RecordDescription', version='1.0')
record_node = ET.Element('record')
root_node.append(record_node)
]:
	i: 
	o: 64(f), 89(t)

nname: 0
n 0(None)[root_node = ET.Element('RecordDescription', version='1.0')
record_node = ET.Element('record')
root_node.append(record_node)
if not self.SaveToXMLNode(record_node):
	log.critical("Failed to save recordinfo '%s'" % strFilePathNameName)
	return False
tree = ET.ElementTree(root_node)
tree.write(strFilePathNameName, encoding='utf-8')
self.info_file_path_name = strFilePathNameName
os.fsync(os.open(strFilePathNameName, os.O_RDWR))
return True
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb776128c>}
nname: 511
n 511(None)[return True
]:
	i: 21(AL), 510()
	o: 

nname: 510
n 510(None)[]:
	i: 430(AF), 446()
	o: 511()

nname: 446
n 446(None)[for idx, file in self.files.items():
node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
]:
	i: 430(for)
	o: 510()

nname: 430
n 430(None)[]:
	i: 21(loop)
	o: 446(for), 510(AF)

nname: 21
n 21(None)[node_information = ET.Element('information')
oXMLNode.append(node_information)
node_temp = ET.Element('name')
node_temp.text = self.name
node_information.append(node_temp)
node_temp = ET.Element('parental_rating')
node_temp.text = str(self.parental_rating)
node_information.append(node_temp)
node_temp = ET.Element('channel')
node_temp.text = self.service_name
node_information.append(node_temp)
node_temp = ET.Element('dvb_service_id')
node_temp.text = str(self.dvb_service_id)
node_information.append(node_temp)
node_temp = ET.Element('start_time')
node_temp.text = str(self.start_time)
node_information.append(node_temp)
node_temp = ET.Element('stop_time')
node_temp.text = str(self.stop_time)
node_information.append(node_temp)
node_temp = ET.Element('size')
node_temp.text = str(self.size)
node_information.append(node_temp)
node_temp = ET.Element('url')
node_temp.text = self.url
node_information.append(node_temp)
node_files = ET.Element('files')
oXMLNode.append(node_files)
]:
	i: 12(), 20()
	o: 430(loop), 511(AL)

nname: 20
n 20(None)[]:
	i: 0(f)
	o: 21()

nname: 12
n 12(None)[return False
]:
	i: 0(t)
	o: 21()

nname: 0
n 0(oXMLNode == None)[]:
	i: 
	o: 12(t), 20(f)

nname: 510
n 510(None)[return True
]:
	i: 430()
	o: 

nname: 430
n 430(None)[for idx, file in self.files.items():
	node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
]:
	i: 0(loop)
	o: 510()

nname: 0
n 0(None)[if oXMLNode == None:
	return False
node_information = ET.Element('information')
oXMLNode.append(node_information)
node_temp = ET.Element('name')
node_temp.text = self.name
node_information.append(node_temp)
node_temp = ET.Element('parental_rating')
node_temp.text = str(self.parental_rating)
node_information.append(node_temp)
node_temp = ET.Element('channel')
node_temp.text = self.service_name
node_information.append(node_temp)
node_temp = ET.Element('dvb_service_id')
node_temp.text = str(self.dvb_service_id)
node_information.append(node_temp)
node_temp = ET.Element('start_time')
node_temp.text = str(self.start_time)
node_information.append(node_temp)
node_temp = ET.Element('stop_time')
node_temp.text = str(self.stop_time)
node_information.append(node_temp)
node_temp = ET.Element('size')
node_temp.text = str(self.size)
node_information.append(node_temp)
node_temp = ET.Element('url')
node_temp.text = self.url
node_information.append(node_temp)
node_files = ET.Element('files')
oXMLNode.append(node_files)
]:
	i: 
	o: 430(loop)

nname: 510
n 510(None)[return True
]:
	i: 0()
	o: 

nname: 0
n 0(None)[if oXMLNode == None:
	return False
node_information = ET.Element('information')
oXMLNode.append(node_information)
node_temp = ET.Element('name')
node_temp.text = self.name
node_information.append(node_temp)
node_temp = ET.Element('parental_rating')
node_temp.text = str(self.parental_rating)
node_information.append(node_temp)
node_temp = ET.Element('channel')
node_temp.text = self.service_name
node_information.append(node_temp)
node_temp = ET.Element('dvb_service_id')
node_temp.text = str(self.dvb_service_id)
node_information.append(node_temp)
node_temp = ET.Element('start_time')
node_temp.text = str(self.start_time)
node_information.append(node_temp)
node_temp = ET.Element('stop_time')
node_temp.text = str(self.stop_time)
node_information.append(node_temp)
node_temp = ET.Element('size')
node_temp.text = str(self.size)
node_information.append(node_temp)
node_temp = ET.Element('url')
node_temp.text = self.url
node_information.append(node_temp)
node_files = ET.Element('files')
oXMLNode.append(node_files)
for idx, file in self.files.items():
	node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
]:
	i: 
	o: 510()

nname: 0
n 0(None)[if oXMLNode == None:
	return False
node_information = ET.Element('information')
oXMLNode.append(node_information)
node_temp = ET.Element('name')
node_temp.text = self.name
node_information.append(node_temp)
node_temp = ET.Element('parental_rating')
node_temp.text = str(self.parental_rating)
node_information.append(node_temp)
node_temp = ET.Element('channel')
node_temp.text = self.service_name
node_information.append(node_temp)
node_temp = ET.Element('dvb_service_id')
node_temp.text = str(self.dvb_service_id)
node_information.append(node_temp)
node_temp = ET.Element('start_time')
node_temp.text = str(self.start_time)
node_information.append(node_temp)
node_temp = ET.Element('stop_time')
node_temp.text = str(self.stop_time)
node_information.append(node_temp)
node_temp = ET.Element('size')
node_temp.text = str(self.size)
node_information.append(node_temp)
node_temp = ET.Element('url')
node_temp.text = self.url
node_information.append(node_temp)
node_files = ET.Element('files')
oXMLNode.append(node_files)
for idx, file in self.files.items():
	node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
return True
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775c14c>}
nname: 234
n 234(None)[return True
]:
	i: 136(AL), 229(), 233()
	o: 

nname: 233
n 233(None)[]:
	i: 70(f)
	o: 234()

nname: 229
n 229(None)[]:
	i: 139(AF), 225()
	o: 234()

nname: 225
n 225(None)[]:
	i: 155(t), 200()
	o: 229()

nname: 200
n 200(None)[log.error("RecordInfo: File '%s' does not exist !" % file)
return False
continue
]:
	i: 155(f)
	o: 225()

nname: 155
n 155(os.path.exists(os.path.join(self.files_folder, file)))[for id, file in self.files.items():
]:
	i: 139(for)
	o: 200(f), 225(t)

nname: 139
n 139(None)[]:
	i: 136(loop)
	o: 155(for), 229(AF)

nname: 136
n 136(None)[]:
	i: 107(), 135()
	o: 139(loop), 234(AL)

nname: 135
n 135(None)[]:
	i: 85(t)
	o: 136()

nname: 107
n 107(None)[log.error("RecordInfo: File '%s' does not exist !" % self.files_folder)
return False
]:
	i: 85(f)
	o: 136()

nname: 85
n 85(os.path.exists(self.files_folder))[]:
	i: 70(t)
	o: 107(f), 135(t)

nname: 70
n 70(self.files_folder != '')[]:
	i: 37(JA), 65(), 69()
	o: 85(t), 233(f)

nname: 69
n 69(None)[]:
	i: 0(f)
	o: 70()

nname: 65
n 65(None)[]:
	i: 15(t)
	o: 70()

nname: 37
n 37(None)[log.error("RecordInfo: File '%s' does not exist !" % self.info_file_path_name)
return False
]:
	i: 15(f)
	o: 70(JA)

nname: 15
n 15(os.path.exists(self.info_file_path_name))[]:
	i: 0(t)
	o: 37(f), 65(t)

nname: 0
n 0(self.info_file_path_name != '')[]:
	i: 
	o: 15(t), 69(f)

nname: 234
n 234(None)[return True
]:
	i: 85(AL), 139(AF), 155(), 0(f)
	o: 

nname: 155
n 155(None)[for id, file in self.files.items():
if not os.path.exists(os.path.join(self.files_folder, file)):
	log.error("RecordInfo: File '%s' does not exist !" % file)
	return False
	continue
]:
	i: 139(for)
	o: 234()

nname: 139
n 139(None)[]:
	i: 85(loop)
	o: 155(for), 234(AF)

nname: 85
n 85(None)[if not os.path.exists(self.files_folder):
	log.error("RecordInfo: File '%s' does not exist !" % self.files_folder)
	return False
]:
	i: 0(t)
	o: 139(loop), 234(AL)

nname: 0
n 0(self.files_folder != '')[if self.info_file_path_name != '':
	if not os.path.exists(self.info_file_path_name):
		log.error("RecordInfo: File '%s' does not exist !" % self.info_file_path_name)
		return False
]:
	i: 
	o: 85(t), 234(f)

self.nodes: {0: <unpyclib.structure.node instance at 0xb775c3ac>, 139: <unpyclib.structure.node instance at 0xb775c4cc>, 234: <unpyclib.structure.node instance at 0xb775c92c>, 85: <unpyclib.structure.node instance at 0xb776178c>, 155: <unpyclib.structure.node instance at 0xb775c86c>}
nname: 342
n 342(None)[]:
	i: 334(JA), 338(), 341()
	o: 

nname: 341
n 341(None)[]:
	i: 229(f)
	o: 342()

nname: 338
n 338(None)[]:
	i: 307(JA), 327(JA), 337()
	o: 342()

nname: 337
n 337(None)[]:
	i: 241(f)
	o: 338()

nname: 327
n 327(None)[]:
	i: 303(except)
	o: 338(JA)

nname: 307
n 307(None)[os.removedirs(self.files_folder)
]:
	i: 303(try)
	o: 338(JA)

nname: 303
n 303(None)[]:
	i: 241(t)
	o: 307(try), 327(except)

nname: 241
n 241(os.path.exists(self.files_folder))[log.info('%s : Is multiple files !' % self.url)
log.info("Delete folder '%s'" % self.files_folder)
]:
	i: 229(t)
	o: 303(t), 337(f)

nname: 229
n 229(self.IsMultipleFiles())[]:
	i: 76(AL), 228()
	o: 241(t), 341(f)

nname: 228
n 228(None)[]:
	i: 79(AF), 225()
	o: 229()

nname: 225
n 225(None)[]:
	i: 179(JA), 214(JA), 224()
	o: 228()

nname: 224
n 224(None)[]:
	i: 95(f), 221()
	o: 225()

nname: 214
n 214(None)[]:
	i: 140(except)
	o: 225(JA)

nname: 179
n 179(None)[os.remove(os.path.join(self.files_folder, file))
]:
	i: 140(try)
	o: 225(JA)

nname: 140
n 140(None)[log.info("Delete '%s'" % os.path.join(self.files_folder, file))
]:
	i: 95(t)
	o: 179(try), 214(except)

nname: 95
n 95(os.path.exists(os.path.join(self.files_folder, file)))[for id, file in self.files.items():
]:
	i: 79(for)
	o: 140(t), 224(f)

nname: 79
n 79(None)[]:
	i: 76(loop)
	o: 95(for), 228(AF)

nname: 76
n 76(None)[]:
	i: 45(JA), 65(JA), 72(), 75()
	o: 79(loop), 229(AL)

nname: 75
n 75(None)[]:
	i: 0(f)
	o: 76()

nname: 65
n 65(None)[]:
	i: 21(except)
	o: 76(JA)

nname: 45
n 45(None)[os.remove(self.info_file_path_name)
]:
	i: 21(try)
	o: 76(JA)

nname: 21
n 21(None)[log.info("Delete '%s'" % self.info_file_path_name)
]:
	i: 0(t)
	o: 45(try), 65(except)

nname: 0
n 0(os.path.exists(self.info_file_path_name))[]:
	i: 
	o: 21(t), 75(f)

nname: 342
n 342(None)[]:
	i: 334(JA), 327(JA), 241(f), 229(f)
	o: 

nname: 327
n 327(None)[except:
	pass
]:
	i: 303()
	o: 342(JA)

nname: 303
n 303(None)[try:
	os.removedirs(self.files_folder)
]:
	i: 241(t)
	o: 327()

nname: 241
n 241(os.path.exists(self.files_folder))[log.info('%s : Is multiple files !' % self.url)
log.info("Delete folder '%s'" % self.files_folder)
]:
	i: 229(t)
	o: 303(t), 342(f)

nname: 229
n 229(self.IsMultipleFiles())[]:
	i: 76(AL), 79(AF), 214(JA), 95(f), 221()
	o: 241(t), 342(f)

nname: 214
n 214(None)[except:
	pass
]:
	i: 140()
	o: 229(JA)

nname: 140
n 140(None)[log.info("Delete '%s'" % os.path.join(self.files_folder, file))
try:
	os.remove(os.path.join(self.files_folder, file))
]:
	i: 95(t)
	o: 214()

nname: 95
n 95(os.path.exists(os.path.join(self.files_folder, file)))[for id, file in self.files.items():
]:
	i: 79(for)
	o: 140(t), 229(f)

nname: 79
n 79(None)[]:
	i: 76(loop)
	o: 95(for), 229(AF)

nname: 76
n 76(None)[]:
	i: 65(JA), 72(), 0(f)
	o: 79(loop), 229(AL)

nname: 65
n 65(None)[except:
	pass
]:
	i: 21()
	o: 76(JA)

nname: 21
n 21(None)[log.info("Delete '%s'" % self.info_file_path_name)
try:
	os.remove(self.info_file_path_name)
]:
	i: 0(t)
	o: 65()

nname: 0
n 0(os.path.exists(self.info_file_path_name))[]:
	i: 
	o: 21(t), 76(f)

nname: 342
n 342(None)[]:
	i: 334(JA), 303(JA), 241(f), 229(f)
	o: 

nname: 303
n 303(None)[try:
	os.removedirs(self.files_folder)
except:
	pass
]:
	i: 241(t)
	o: 342(JA)

nname: 241
n 241(os.path.exists(self.files_folder))[log.info('%s : Is multiple files !' % self.url)
log.info("Delete folder '%s'" % self.files_folder)
]:
	i: 229(t)
	o: 303(t), 342(f)

nname: 229
n 229(self.IsMultipleFiles())[]:
	i: 76(AL), 79(AF), 140(JA), 95(f), 221()
	o: 241(t), 342(f)

nname: 140
n 140(None)[log.info("Delete '%s'" % os.path.join(self.files_folder, file))
try:
	os.remove(os.path.join(self.files_folder, file))
except:
	pass
]:
	i: 95(t)
	o: 229(JA)

nname: 95
n 95(os.path.exists(os.path.join(self.files_folder, file)))[for id, file in self.files.items():
]:
	i: 79(for)
	o: 140(t), 229(f)

nname: 79
n 79(None)[]:
	i: 76(loop)
	o: 95(for), 229(AF)

nname: 76
n 76(None)[]:
	i: 21(JA), 72(), 0(f)
	o: 79(loop), 229(AL)

nname: 21
n 21(None)[log.info("Delete '%s'" % self.info_file_path_name)
try:
	os.remove(self.info_file_path_name)
except:
	pass
]:
	i: 0(t)
	o: 76(JA)

nname: 0
n 0(os.path.exists(self.info_file_path_name))[]:
	i: 
	o: 21(t), 76(f)

nname: 342
n 342(None)[]:
	i: 334(JA), 229(f)
	o: 

nname: 229
n 229(None)[if self.IsMultipleFiles():
	log.info('%s : Is multiple files !' % self.url)
	log.info("Delete folder '%s'" % self.files_folder)
	if os.path.exists(self.files_folder):
		try:
			os.removedirs(self.files_folder)
		except:
			pass
]:
	i: 95(f), 221()
	o: 342(JA)

nname: 95
n 95(None)[for id, file in self.files.items():
	if os.path.exists(os.path.join(self.files_folder, file)):
		log.info("Delete '%s'" % os.path.join(self.files_folder, file))
		try:
			os.remove(os.path.join(self.files_folder, file))
		except:
			pass
]:
	i: 76(for)
	o: 229(JA)

nname: 76
n 76(None)[]:
	i: 72(), 0(f)
	o: 95(for)

nname: 0
n 0(None)[if os.path.exists(self.info_file_path_name):
	log.info("Delete '%s'" % self.info_file_path_name)
	try:
		os.remove(self.info_file_path_name)
	except:
		pass
]:
	i: 
	o: 76(JA)

nname: 342
n 342(None)[]:
	i: 334(JA), 229(f)
	o: 

nname: 229
n 229(None)[if self.IsMultipleFiles():
	log.info('%s : Is multiple files !' % self.url)
	log.info("Delete folder '%s'" % self.files_folder)
	if os.path.exists(self.files_folder):
		try:
			os.removedirs(self.files_folder)
		except:
			pass
]:
	i: 76(f), 221()
	o: 342(JA)

nname: 76
n 76(None)[for id, file in self.files.items():
	if os.path.exists(os.path.join(self.files_folder, file)):
		log.info("Delete '%s'" % os.path.join(self.files_folder, file))
		try:
			os.remove(os.path.join(self.files_folder, file))
		except:
			pass
]:
	i: 72(), 0(f)
	o: 229(JA)

nname: 0
n 0(None)[if os.path.exists(self.info_file_path_name):
	log.info("Delete '%s'" % self.info_file_path_name)
	try:
		os.remove(self.info_file_path_name)
	except:
		pass
]:
	i: 
	o: 76(JA)

self.nodes: {0: <unpyclib.structure.node instance at 0xb775ceac>, 342: <unpyclib.structure.node instance at 0xb776402c>, 71: <unpyclib.structure.node instance at 0xb7764c4c>, 72: <unpyclib.structure.node instance at 0xb7764a0c>, 76: <unpyclib.structure.node instance at 0xb775c18c>, 333: <unpyclib.structure.node instance at 0xb77643ac>, 334: <unpyclib.structure.node instance at 0xb77644cc>, 220: <unpyclib.structure.node instance at 0xb776444c>, 221: <unpyclib.structure.node instance at 0xb7764f4c>, 229: <unpyclib.structure.node instance at 0xb775c72c>}
nname: 6
n 6(None)[def __init__(self):
	self.name = ''
	self.parental_rating = 0
	self.service_name = ''
	self.start_time = 0
	self.stop_time = 0
	self.size = 0
	self.url = ''
	self.info_file_path_name = ''
	self.files = {}
	self.files_folder = ''

def __str__(self):
	text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
	for id, file in self.files.items():
		text += 'File %s\n' % file
	return text

def compute_parental_rating(self):
	self.parental_rating = 0
	try:
		service = container_search(get_root('channel'), 'title', self.service_name)[0]
		options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
		if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
			pass

def IsMultipleFiles(self):
	if self.url != '':
		if self.url.startswith(URL_PREFIX_TIMESHIFT):
			return True
	return False

def Save(self, url, dvb_service_id):
	self.files = {}
	self.url = ''
	self.info_file_path_name = ''

def LoadFromFile(self, strFilePathNameName):
	try:
		node_root = ET.parse(strFilePathNameName)
	except:
		log.critical("Can not parse xml file '%s'" % strFilePathNameName)
		return False
	node_root = node_root.find('record')
	if not node_root:
		log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
		return False
	if not self.LoadFromXML(node_root):
		self.info_file_path_name = ''
		return False
	self.info_file_path_name = strFilePathNameName
	self.files_folder = os.path.dirname(self.info_file_path_name)
	return True

def LoadFromXML(self, oXMLNode):
	self.files = {}
	self.name = ''
	self.parental_rating = 0
	self.service_name = ''
	self.start_time = 0
	self.stop_time = 0
	self.url = ''
	node_information = oXMLNode.find('information')
	if node_information == None:
		log.error("Invalide Record Info file : No 'information' xml node found")
		return False
	node_files = oXMLNode.find('files')
	if node_files == None:
		log.error("Invalide Record Info file : No 'files' xml node found")
		return False
	self.name = node_information.find('name').text
	self.parental_rating = int(node_information.find('parental_rating').text)
	self.service_name = node_information.find('channel').text
	self.dvb_service_id = int(node_information.find('dvb_service_id').text)
	self.start_time = int(node_information.find('start_time').text)
	self.stop_time = int(node_information.find('stop_time').text)
	if node_information.find('size'):
		self.size = int(node_information.find('size').text)
	self.url = node_information.find('url').text
	nodes_file = node_files.getiterator('file')
	for node_file in nodes_file:
		self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
	return True

def SaveToFile(self, strFilePathNameName):
	root_node = ET.Element('RecordDescription', version='1.0')
	record_node = ET.Element('record')
	root_node.append(record_node)
	if not self.SaveToXMLNode(record_node):
		log.critical("Failed to save recordinfo '%s'" % strFilePathNameName)
		return False
	tree = ET.ElementTree(root_node)
	tree.write(strFilePathNameName, encoding='utf-8')
	self.info_file_path_name = strFilePathNameName
	os.fsync(os.open(strFilePathNameName, os.O_RDWR))
	return True

def SaveToXMLNode(self, oXMLNode):
	if oXMLNode == None:
		return False
	node_information = ET.Element('information')
	oXMLNode.append(node_information)
	node_temp = ET.Element('name')
	node_temp.text = self.name
	node_information.append(node_temp)
	node_temp = ET.Element('parental_rating')
	node_temp.text = str(self.parental_rating)
	node_information.append(node_temp)
	node_temp = ET.Element('channel')
	node_temp.text = self.service_name
	node_information.append(node_temp)
	node_temp = ET.Element('dvb_service_id')
	node_temp.text = str(self.dvb_service_id)
	node_information.append(node_temp)
	node_temp = ET.Element('start_time')
	node_temp.text = str(self.start_time)
	node_information.append(node_temp)
	node_temp = ET.Element('stop_time')
	node_temp.text = str(self.stop_time)
	node_information.append(node_temp)
	node_temp = ET.Element('size')
	node_temp.text = str(self.size)
	node_information.append(node_temp)
	node_temp = ET.Element('url')
	node_temp.text = self.url
	node_information.append(node_temp)
	node_files = ET.Element('files')
	oXMLNode.append(node_files)
	for idx, file in self.files.items():
		node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
	return True

def IsValid(self):
	if self.info_file_path_name != '':
		if not os.path.exists(self.info_file_path_name):
			log.error("RecordInfo: File '%s' does not exist !" % self.info_file_path_name)
			return False

def Delete(self):
	if os.path.exists(self.info_file_path_name):
		log.info("Delete '%s'" % self.info_file_path_name)
		try:
			os.remove(self.info_file_path_name)
		except:
			pass

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7754eac>}
nname: 0
n 0(None)[__doc__ = '\nRecordingInfo class implementation\n'
import xml.etree.cElementTree as ET
import os
from logger import log
from config import *
from wymedia.wmplus import browse_ng, get_root, container_search
class RecordInfo(object):
	def __init__(self):
		self.name = ''
		self.parental_rating = 0
		self.service_name = ''
		self.start_time = 0
		self.stop_time = 0
		self.size = 0
		self.url = ''
		self.info_file_path_name = ''
		self.files = {}
		self.files_folder = ''

	def __str__(self):
		text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
		for id, file in self.files.items():
			text += 'File %s\n' % file
		return text

	def compute_parental_rating(self):
		self.parental_rating = 0
		try:
			service = container_search(get_root('channel'), 'title', self.service_name)[0]
			options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
			if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
				pass

	def IsMultipleFiles(self):
		if self.url != '':
			if self.url.startswith(URL_PREFIX_TIMESHIFT):
				return True
		return False

	def Save(self, url, dvb_service_id):
		self.files = {}
		self.url = ''
		self.info_file_path_name = ''

	def LoadFromFile(self, strFilePathNameName):
		try:
			node_root = ET.parse(strFilePathNameName)
		except:
			log.critical("Can not parse xml file '%s'" % strFilePathNameName)
			return False
		node_root = node_root.find('record')
		if not node_root:
			log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
			return False
		if not self.LoadFromXML(node_root):
			self.info_file_path_name = ''
			return False
		self.info_file_path_name = strFilePathNameName
		self.files_folder = os.path.dirname(self.info_file_path_name)
		return True

	def LoadFromXML(self, oXMLNode):
		self.files = {}
		self.name = ''
		self.parental_rating = 0
		self.service_name = ''
		self.start_time = 0
		self.stop_time = 0
		self.url = ''
		node_information = oXMLNode.find('information')
		if node_information == None:
			log.error("Invalide Record Info file : No 'information' xml node found")
			return False
		node_files = oXMLNode.find('files')
		if node_files == None:
			log.error("Invalide Record Info file : No 'files' xml node found")
			return False
		self.name = node_information.find('name').text
		self.parental_rating = int(node_information.find('parental_rating').text)
		self.service_name = node_information.find('channel').text
		self.dvb_service_id = int(node_information.find('dvb_service_id').text)
		self.start_time = int(node_information.find('start_time').text)
		self.stop_time = int(node_information.find('stop_time').text)
		if node_information.find('size'):
			self.size = int(node_information.find('size').text)
		self.url = node_information.find('url').text
		nodes_file = node_files.getiterator('file')
		for node_file in nodes_file:
			self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
		return True

	def SaveToFile(self, strFilePathNameName):
		root_node = ET.Element('RecordDescription', version='1.0')
		record_node = ET.Element('record')
		root_node.append(record_node)
		if not self.SaveToXMLNode(record_node):
			log.critical("Failed to save recordinfo '%s'" % strFilePathNameName)
			return False
		tree = ET.ElementTree(root_node)
		tree.write(strFilePathNameName, encoding='utf-8')
		self.info_file_path_name = strFilePathNameName
		os.fsync(os.open(strFilePathNameName, os.O_RDWR))
		return True

	def SaveToXMLNode(self, oXMLNode):
		if oXMLNode == None:
			return False
		node_information = ET.Element('information')
		oXMLNode.append(node_information)
		node_temp = ET.Element('name')
		node_temp.text = self.name
		node_information.append(node_temp)
		node_temp = ET.Element('parental_rating')
		node_temp.text = str(self.parental_rating)
		node_information.append(node_temp)
		node_temp = ET.Element('channel')
		node_temp.text = self.service_name
		node_information.append(node_temp)
		node_temp = ET.Element('dvb_service_id')
		node_temp.text = str(self.dvb_service_id)
		node_information.append(node_temp)
		node_temp = ET.Element('start_time')
		node_temp.text = str(self.start_time)
		node_information.append(node_temp)
		node_temp = ET.Element('stop_time')
		node_temp.text = str(self.stop_time)
		node_information.append(node_temp)
		node_temp = ET.Element('size')
		node_temp.text = str(self.size)
		node_information.append(node_temp)
		node_temp = ET.Element('url')
		node_temp.text = self.url
		node_information.append(node_temp)
		node_files = ET.Element('files')
		oXMLNode.append(node_files)
		for idx, file in self.files.items():
			node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
		return True

	def IsValid(self):
		if self.info_file_path_name != '':
			if not os.path.exists(self.info_file_path_name):
				log.error("RecordInfo: File '%s' does not exist !" % self.info_file_path_name)
				return False

	def Delete(self):
		if os.path.exists(self.info_file_path_name):
			log.info("Delete '%s'" % self.info_file_path_name)
			try:
				os.remove(self.info_file_path_name)
			except:
				pass



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb774dc6c>}
__doc__ = '\nRecordingInfo class implementation\n'
import xml.etree.cElementTree as ET
import os
from logger import log
from config import *
from wymedia.wmplus import browse_ng, get_root, container_search
class RecordInfo(object):
	def __init__(self):
		self.name = ''
		self.parental_rating = 0
		self.service_name = ''
		self.start_time = 0
		self.stop_time = 0
		self.size = 0
		self.url = ''
		self.info_file_path_name = ''
		self.files = {}
		self.files_folder = ''

	def __str__(self):
		text = 'Record : name = %s, service_name = %s, start_time = %d, stop_time = %d, url = %s, info_file = %s\n' % (self.name, self.service_name, self.start_time, self.stop_time, self.url, self.info_file_path_name)
		for id, file in self.files.items():
			text += 'File %s\n' % file
		return text

	def compute_parental_rating(self):
		self.parental_rating = 0
		try:
			service = container_search(get_root('channel'), 'title', self.service_name)[0]
			options = {'universe': 'tv', 'serviceId': service['serviceId'], 'scheduledStartTime': str(int(self.start_time)), 'scheduledEndTime': str(int(self.stop_time))}
			if not browse_ng(get_root('epg'), 0, -1, ['+scheduledStartTime'], options):
				pass

	def IsMultipleFiles(self):
		if self.url != '':
			if self.url.startswith(URL_PREFIX_TIMESHIFT):
				return True
		return False

	def Save(self, url, dvb_service_id):
		self.files = {}
		self.url = ''
		self.info_file_path_name = ''

	def LoadFromFile(self, strFilePathNameName):
		try:
			node_root = ET.parse(strFilePathNameName)
		except:
			log.critical("Can not parse xml file '%s'" % strFilePathNameName)
			return False
		node_root = node_root.find('record')
		if not node_root:
			log.critical('The file ' + str(strFilePathNameName) + ' is not a valid redordinfo')
			return False
		if not self.LoadFromXML(node_root):
			self.info_file_path_name = ''
			return False
		self.info_file_path_name = strFilePathNameName
		self.files_folder = os.path.dirname(self.info_file_path_name)
		return True

	def LoadFromXML(self, oXMLNode):
		self.files = {}
		self.name = ''
		self.parental_rating = 0
		self.service_name = ''
		self.start_time = 0
		self.stop_time = 0
		self.url = ''
		node_information = oXMLNode.find('information')
		if node_information == None:
			log.error("Invalide Record Info file : No 'information' xml node found")
			return False
		node_files = oXMLNode.find('files')
		if node_files == None:
			log.error("Invalide Record Info file : No 'files' xml node found")
			return False
		self.name = node_information.find('name').text
		self.parental_rating = int(node_information.find('parental_rating').text)
		self.service_name = node_information.find('channel').text
		self.dvb_service_id = int(node_information.find('dvb_service_id').text)
		self.start_time = int(node_information.find('start_time').text)
		self.stop_time = int(node_information.find('stop_time').text)
		if node_information.find('size'):
			self.size = int(node_information.find('size').text)
		self.url = node_information.find('url').text
		nodes_file = node_files.getiterator('file')
		for node_file in nodes_file:
			self.files[int(node_file.attrib['index'])] = node_file.attrib['file_path_name']
		return True

	def SaveToFile(self, strFilePathNameName):
		root_node = ET.Element('RecordDescription', version='1.0')
		record_node = ET.Element('record')
		root_node.append(record_node)
		if not self.SaveToXMLNode(record_node):
			log.critical("Failed to save recordinfo '%s'" % strFilePathNameName)
			return False
		tree = ET.ElementTree(root_node)
		tree.write(strFilePathNameName, encoding='utf-8')
		self.info_file_path_name = strFilePathNameName
		os.fsync(os.open(strFilePathNameName, os.O_RDWR))
		return True

	def SaveToXMLNode(self, oXMLNode):
		if oXMLNode == None:
			return False
		node_information = ET.Element('information')
		oXMLNode.append(node_information)
		node_temp = ET.Element('name')
		node_temp.text = self.name
		node_information.append(node_temp)
		node_temp = ET.Element('parental_rating')
		node_temp.text = str(self.parental_rating)
		node_information.append(node_temp)
		node_temp = ET.Element('channel')
		node_temp.text = self.service_name
		node_information.append(node_temp)
		node_temp = ET.Element('dvb_service_id')
		node_temp.text = str(self.dvb_service_id)
		node_information.append(node_temp)
		node_temp = ET.Element('start_time')
		node_temp.text = str(self.start_time)
		node_information.append(node_temp)
		node_temp = ET.Element('stop_time')
		node_temp.text = str(self.stop_time)
		node_information.append(node_temp)
		node_temp = ET.Element('size')
		node_temp.text = str(self.size)
		node_information.append(node_temp)
		node_temp = ET.Element('url')
		node_temp.text = self.url
		node_information.append(node_temp)
		node_files = ET.Element('files')
		oXMLNode.append(node_files)
		for idx, file in self.files.items():
			node_files.append(ET.Element('file', index=str(idx), file_path_name=os.path.basename(file)))
		return True

	def IsValid(self):
		if self.info_file_path_name != '':
			if not os.path.exists(self.info_file_path_name):
				log.error("RecordInfo: File '%s' does not exist !" % self.info_file_path_name)
				return False

	def Delete(self):
		if os.path.exists(self.info_file_path_name):
			log.info("Delete '%s'" % self.info_file_path_name)
			try:
				os.remove(self.info_file_path_name)
			except:
				pass



